﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using XinGuanERP.Attributes.system;
using XinGuanERP.Models.Vo.business;
using XinGuanERP.Services.business.IServices;
using XinGuanERP.Utils;

namespace XinGuanERP.Controllers.business;
[DynamicApiController]
public class SuppilerController
{
    private readonly ISuppilerService _suppilerService;
    public SuppilerController(ISuppilerService suppilerService)
    {
        _suppilerService = suppilerService;
    }
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil AddSuppiler(SuppilerVo suppilerVo) =>
        ResultUtil.ok(_suppilerService.AddSuppiler(suppilerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil UpdateSuppiler(SuppilerVo suppilerVo) =>
        ResultUtil.ok(_suppilerService.UpdateSuppiler(suppilerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil DeleteSuppiler(string id) =>
        ResultUtil.ok(_suppilerService.DeleteSuppiler(id));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    [HttpPost]
    public ResultUtil GetSuppilerWithPage(SuppilerVo suppilerVo) =>
        ResultUtil.ok(_suppilerService.GetSuppilerWithPage(suppilerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil GetSuppilerWithList() =>
        ResultUtil.ok(_suppilerService.GetSuppilerWithList());
}